/**
 *
 * index
 * loop 1 to N{
 * if( i == t){
 * => i
 * }
 * if(check i value < t){
 * check if last item, => index + 1
 * index  = i
 * }
 *
 * if(check i value > t){
 * index++
 * => index
 * }
 */
fun searchInsert(nums: IntArray, target: Int): Int {
    var right = nums.size - 1
    var left = 0;
    var m = 0
    while (left <= right) {
        // 1, 7 => 4 + 1 => 5
        m = (left + right) / 2 + left
        if (nums[m] == target) {
            return m
        } else if (nums[m] < target)     {
            left = m
            m = (left + right) / 2
        } else {
            if (m == 0) {
                return m
            }
            right = m
            m = (left + right) / 2
        }
    }
    return m
}